package cn.example.backstage.examination.service.impl;

import cn.example.backstage.examination.mapper.ExaminationMapper;
import cn.example.backstage.examination.pojo.dto.ExaminationAddDTO;
import cn.example.backstage.examination.pojo.dto.ExaminationQuery;
import cn.example.backstage.examination.pojo.vo.ExaminationVO;
import cn.example.backstage.examination.service.ExaminationService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
public class ExaminationServiceImpl implements ExaminationService {
    @Autowired
    ExaminationMapper examinationMapper;
    @Override
    public List<ExaminationVO> selectAll(ExaminationQuery examinationQuery) {
        List<ExaminationVO> list = examinationMapper.select(examinationQuery);
        return list;
    }
    @Override
    public void addExamination(ExaminationAddDTO examinationAddDTO) {
        if (examinationAddDTO.getId() == null){
            examinationMapper.insert(examinationAddDTO);
        }else {
            examinationMapper.update(examinationAddDTO);
        }
    }
    @Override
    public void deleteById(Long id) {
        examinationMapper.deleteById(id);
    }
}
